<head>
    <link href="${ctx}/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link href="${ctx}/font-awesome/3.0.0/css/font-awesome.min.css" rel="stylesheet">
    <link href="${ctx}/css/index.css" rel="stylesheet">
    <link href="${ctx}/bootstrap-table/1.12.0/bootstrap-table.min.css" rel="stylesheet">
    <script src="${ctx}/jquery/2.1.4/jquery.min.js"></script>
    <script src="${ctx}/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="${ctx}/bootstrap-table/1.12.0/bootstrap-table.min.js"></script>
    <script src="${ctx}/bootstrap-table/1.12.0/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="${ctx}/bootstrap-table/1.12.0/extensions/export/bootstrap-table-export.min.js"></script>
    <script src="${ctx}/js/extends.js"></script>
    <script src="${ctx}/layui/layui.all.js"></script>
    <script src="${ctx}/js/util.js"></script>
    <link href="${ctx}/layui/css/layui.css" rel="stylesheet">
    <style>
        .btn {
            font-size: 12px;
        }

    </style>
    <style scoped>
        body {
            min-width: auto;
        }

        .layui-input-block {
            margin-left: 0 !important;
        }

        .layui-form-label {
            width: 110px;
        }

        .layui-form-item {
            margin-bottom: 18px;
        }
    </style>
</head>
<body>
<br><br>

<form class="layui-form pl-20 pr-20" action="" lay-filter="item" style="width: 500px;margin: 0 auto;">
    <input type="hidden" name="id" readonly value="${item.id!''}">


    <div class="layui-form-item">
        <label class="layui-form-label col-xs-3 col-sm-3" style="width: 148px;padding-right: 0"><span
                    class="c-red">*</span>选择父级菜单名称：</label>
        <div class="layui-input-block col-xs-8 col-sm-8">
            <select name="parent" lay-verify="required">
                <option value="0">无父级</option>
                <#list parentlist as list>
                    <#if item.category!='Menu'>
                        <option value="${list.resource}"
                                <#if item.resource??&&item.parent==list.resource>
                                    selected=""
                                </#if>
                        >${list.title}</option>
                    </#if>
                </#list>


            </select>
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label col-xs-3 col-sm-3" style="width: 148px;padding-right: 0"><span
                    class="c-red">*</span>标题：</label>
        <div class="layui-input-block col-xs-8 col-sm-8" style="width:333px">
            <input type="text" name="title"
                   lay-verify="required" placeholder="请输入标题"
                   autocomplete="off" class="layui-input" value="${item.title!''}">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label col-xs-3 col-sm-3" style="width: 148px;padding-right: 0"><span
                    class="c-red">*</span>图标：</label>
        <div class="layui-input-block col-xs-8 col-sm-8" style="width: 333px">
            <input type="text" name="icon"
                   placeholder="请输入图标"
                   autocomplete="off" class="layui-input" value="${item.icon!''}">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label col-xs-3 col-sm-3" style="width: 148px;padding-right: 0"><span
                    class="c-red">*</span>访问路径：</label>
        <div class="layui-input-block col-xs-8 col-sm-8" style="width: 333px">
            <input type="text" name="path"
                   lay-verify="required" placeholder="请输入访问路径"
                   autocomplete="off" class="layui-input" value="${item.path!''}">
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label col-xs-3 col-sm-3" style="width: 148px;padding-right: 0"><span
                    class="c-red">*</span>排序：</label>
        <div class="layui-input-block col-xs-8 col-sm-8" style="width: 333px">
            <input type="text" name="sort"
                   lay-verify="required" placeholder="请输入排序"
                   autocomplete="off" class="layui-input" value="${item.sort!''}">
        </div>
    </div>


    <div class="layui-form-item" style="display: flex;padding-left:165px">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formUpdate">保存</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>


<script>

    $(document).ready(function () {
        layui.use('form', function () {

            var form = layui.form;
            form.render();
            form.on('submit(formUpdate)', function (data) {
                $.ajax({
                    url: "/resource/edit",    //请求的url地址
                    dataType: "json",   //返回格式为json
                    async: true,//请求是否异步，默认为异步，这也是ajax重要特性
                    data: data.field,    //参数值,键值对
                    type: "post",   //请求方式
                    beforeSend: function () {
                        //请求前的处理
                    },
                    success: function (req) {
                        //请求成功时处理
                        if (req.success) {
                            parent.showmsg(req.message);
                            parent.search();
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.layer.close(index); //再执行关闭

                        } else {
                            layer.msg(req.message)
                        }
                    },
                    complete: function () {
                        //请求完成的处理
                    },
                    error: function () {
                        //请求出错处理
                        layer.msg("请重试！若在失败请联系管理员")
                    }
                });

                return false;
            });
        });
    });

</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>